import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info', // 假设有获取用户信息的接口
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/user/logout', // 假设有登出接口
    method: 'post'
  })
}

// 分页查询用户
export function findPage(params) {
  return request({
    url: '/user/page',
    method: 'get',
    params
  })
}

// 新增或更新用户
export function save(data) {
  return request({
    url: '/user',
    method: 'post',
    data
  })
}

// 删除用户
export function deleteById(id) {
  return request({
    url: `/user/${id}`,
    method: 'delete'
  })
}

// 批量删除用户
export function deleteBatch(ids) {
  return request({
    url: '/user/del/batch',
    method: 'post',
    data: ids
  })
}

// 查询所有用户
export function findAll() {
  return request({
    url: '/user',
    method: 'get'
  })
}

// 根据ID查询用户
export function findOne(id) {
  return request({
    url: `/user/${id}`,
    method: 'get'
  })
}

// 获取验证码
export function getCaptcha() {
  return request({
    url: '/captcha',
    method: 'get'
  })
}
